/*
 * @Author: sheneg sheneg@op-mobile.com.cn
 * @Date: 2023-07-12 15:40:39
 * @LastEditors: sheneg sheneg@op-mobile.com.cn
 * @LastEditTime: 2023-07-12 20:17:42
 * @FilePath: \jxtech-web-starter\src\api\org\api-permission.ts
 * @Description: api权限管理树
 */
import { AxiosResponse } from 'axios';
import { ReturnTree } from '@whjxtech/jxtech-component';
import service from '/@/utils/request';
import { SERVICE_CONFIG } from '../_base';

const baseUrl = SERVICE_CONFIG.ORG + '/org/CompResourceService';

/**
 * 检修部位树节点类型
 */
export type OrgUnitTreeNode = {
  /**生效日期 */
  enabledDate: string;
  /**排序号 */
  orderNum: number;
  /**部门级别 */
  privLevel: string;
  /**部门id */
  unitId: string;
  /**部门编码 */
  unitCode: string;
  /**部门类型 */
  unitType: string;
  /**部门名称 */
  unitDescription: string;
  /**是否有效 Y|N */
  valid: string;
  /**组织id */
  orgId: string;
  /**父亲id */
  parentId: string;
  /**子组织id */
  subOrgId: string;
};

/**
 * 获取api权限树
 * @param queryparam 查询参数
 */
export function orgApiTree(
  queryparam?: any
): Promise<AxiosResponse<ReturnTree<OrgUnitTreeNode>[]>> {
  var url = baseUrl + '/apiTree';
  return service.get(url, { params: queryparam });
}

/**
 * 获取api权限树
 * @param queryparam 查询参数
 */
export function orgApiFormQueryById(queryparam?: any) {
  var url = baseUrl + '/queryById';
  return service.get(url, { params: queryparam });
}

/**
 * api权限树结构编辑保存
 * @param queryparam 查询参数
 */
export function saveUpdate(queryparam?: any) {
  var url = baseUrl + '/saveUpdate';
  return service.post(url, queryparam);
}

/**
 * api权限树结构新增保存
 * @param queryparam 查询参数
 */
export function insertPermissionTree(queryparam?: any) {
  var url = baseUrl;
  return service.post(url, queryparam);
}
